package com.ce.webframework.sec.vo;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.sitechasia.webx.core.model.IViewObject;

/**
*
* <p>版权所有：中企动力
* <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
* <p>功能描述：消息提示VO对象
*
* @author kuanglingxuan
* Created on 2007-7-25
*/
public class SecMsgTipsVO implements IViewObject {

	protected Long msgTipId;//消息id

	protected String msgText;//消息文本

	protected Date sendTime;//日期

	protected String url;//跳转页面url

	protected String sender;//发送者名字

	protected String receiver;//接收者名字

	protected String senderCode;//发送者用户编码

	protected String receiverCode;//接收者用户编码

	protected Character readFlag;//阅读标志

	protected Date endTime;//结束时间

	protected Date remindTime;//提醒时间

	protected Date receiveTime;//消息接收时间

	public Date getReceiveTime() {
		return receiveTime;
	}

	public void setReceiveTime(Date receiveTime) {
		this.receiveTime = receiveTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public void setRemindTime(Date remindTime) {
		this.remindTime = remindTime;
	}

	public Date getRemindTime() {
		return remindTime;
	}

	public SecMsgTipsVO(){}

	public SecMsgTipsVO(String msgText, String url, Date sendTime){
		this.msgText = msgText;
		this.url = url;
		this.sendTime = sendTime;
	}

	public SecMsgTipsVO(Long msgTipId, Date remindTime, String receiverCode){
		this.msgTipId = msgTipId;
		this.remindTime = remindTime;
		this.receiverCode = receiverCode;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public String getMsgText() {
		return msgText;
	}

	public void setMsgText(String msgText) {
		this.msgText = msgText;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	/**
	 * 格式日期输出��ʽ���ʱ��
	 * @return
	 */
	public String getFormatDateTime(){
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return dateFormat.format(sendTime);
	}

	/**
	 * 精简消息文本Ը�ʽ���ı�
	 * @return
	 */
	public String getFormatMsgText(){

		int position = 0;
		int charVal;
		int byteCount = 0;
		if(countLength(msgText) > 80){
			while (byteCount <= 80) {
				Character ch  = new Character(msgText.charAt(position));
				charVal = (int) ch.charValue();
				if (charVal > 255 || charVal < 0 || (charVal > 64 && charVal < 91)) {
					byteCount ++;
				}
				byteCount ++;
				position++;
			}
			return msgText.substring(0, position - 1) + "...";
		}
		return msgText;

	}
	private int countLength(String str) {
		int length = 0;
		for (int i = 0; i < str.length(); i ++) {
			Character ch  = new Character(str.charAt(i));
			int charVal = (int) ch.charValue();
			if (charVal > 255 || charVal < 0 || (charVal > 64 && charVal < 91)) {
				length ++;
			}
			length ++;
		}
		return length;
	}

	public String getReceiverCode() {
		return receiverCode;
	}

	public void setReceiverCode(String receiverCode) {
		this.receiverCode = receiverCode;
	}

	public String getSenderCode() {
		return senderCode;
	}

	public void setSenderCode(String senderCode) {
		this.senderCode = senderCode;
	}

	public Long getMsgTipId() {
		return msgTipId;
	}

	public void setMsgTipId(Long msgTipId) {
		this.msgTipId = msgTipId;
	}

	public Character getReadFlag() {
		return readFlag;
	}

	public void setReadFlag(Character readFlag) {
		this.readFlag = readFlag;
	}
}
